package com.tm.d1.properties;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Properties;
import java.util.Set;

/**
 * 2024/6/20 掌握使用属性文件中的键值对数据到properties对象中去
 */
public class ProperitesTest1 {
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        System.out.println(properties);

        //2.开始加载属性文件中的键值对数据到properties对象中去
        properties.load(new FileReader("properties-app\\src\\main\\resources\\application.properties"));
        System.out.println(properties);

        //2.开始加载属性文件中的键值对数据到properties对象中去
        properties.load(new FileReader("properties-app\\src\\main\\resources\\application.properties"));
        System.out.println(properties);
        
        //3.根据键取值
        System.out.println(properties.getProperty("张无忌"));
        System.out.println(properties.getProperty("赵敏"));

        
        //4.遍历全部的键和值
        Set<String> keys = properties.stringPropertyNames();
        for (String key : keys) {
            String value = properties.getProperty(key);
            System.out.println(key + value);
        }
    }
}
